<?php
$menumark = 'user';
switch ($act) {
    //#####################@ 修改分类 @#####################//
    case 'find':

        $sql = "select * from wxgg_user where user_wxname like '%{$_p_wxid}%'";
        $user = $db->sql_selectall($sql);
        include(pe_tpl('user_list.html'));
        break;

    case 'edit':
        include(pe_tpl('user_edit.html'));
        break;

    case 'add':
        include(pe_tpl('user_add.html'));
        break;
    //#####################@ 分类列表 @#####################//

    case 'detail':
        $order = $db->pe_selectall('order',array('order_userid'=>$_g_id));
        foreach ($order as $k => $v) {
            $house = $db->pe_select('house', array('house_id' => $v['order_houseid']));
            $order[$k]['order_housename'] = $house['house_name'];
        }

        include(pe_tpl('user_detail.html'));
        break;

    case 'charge':
        $user = $db->pe_select('user',array('user_id'=>$_g_id));
        if(!empty($user)){
            $charge_record = $db->pe_selectall('moneycard_record',array('record_wxid'=>$user['user_wxid']));
        }


        include(pe_tpl('user_charge.html'));
        break;

    case 'cool':
        if($db->pe_update('user',array('user_id'=>$_g_id),array('user_state'=>0))){
            pe_success('冻结成功','admin.php?mod=user');
        }else{
            pe_error('冻结失败','admin.php?mod=user');
        }
        include(pe_tpl('order_detail.html'));
        break;

    case 'recover':
        if($db->pe_update('user',array('user_id'=>$_g_id),array('user_state'=>1))){
            pe_success('恢复成功','admin.php?mod=user');
        }else{
            pe_error('恢复失败','admin.php?mod=user');
        }
        include(pe_tpl('order_detail.html'));
        break;

    default :

//        $sql = 'select u.user_id,u.user_name,u.user_headimg,u.user_wxid,u.user_phone,u.user_state,v.vipcard_category_id,vci.vipcategory_name from wxgg_user as u join wxgg_vipcard as v on u.user_vipcard_number = v.vipcard_number join wxgg_vipcategory as vci on v.vipcard_category_id = vci.vipcategory_id where u.user_id != 0';
//        $user = $db->sql_selectall($sql);

        $user = $db->pe_selectall('user');
        foreach ($user as $k=> $v){
            $vipcard = $db->pe_select('vipcard',array('vipcard_number'=>$v['user_vipcard_number']));
            if(!empty($vipcard)){
                $user[$k]['vipcategory_name'] = $vipcard['vipcard_name'];
            }else{
                $user[$k]['vipcategory_name'] = "无";
            }
        }

//        mp($user);exit;
        include(pe_tpl('user_list.html'));

        break;
}
?>